<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>代理提现汇总</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
    <style>
        .layui-table-body .layui-table-cell {
            height: 50px; line-height: 50px;
        }
        .layui-laypage .layui-laypage-curr .layui-laypage-em{ background-color: #1E9FFF; }
        .layui-form-checked[lay-skin=primary] i{border-color: #1E9FFF!important;background-color: #1E9FFF;color:#fff;}
        .layui-form-checkbox[lay-skin=primary]:hover i{border-color:#1E9FFF;color:#fff}
        p.money {
            color: #f8a20f;
            font-size: 30px;
            font-weight: bold;
            height: 35px;
            line-height: 35px;
            padding: 5px 0;
            padding-bottom: 15px;
        }
    </style>
</head>
<body>

<div class="layui-fluid">

    <div class="layui-row layui-col-space1">
        <div class="layui-col-sm12">
            <!-- 填充内容 -->
            <div class="layui-card">
                <div class="layui-card-header">友情提示</div>
                <div class="layui-card-body" >
                    <p>1、最近结算日期为代理截止到这一天所有已结算分成金额（包含已审未打款）</p>
                </div>
            </div>
        </div>
    </div>

    <div class="layui-row layui-col-space15">
        <div class="layui-col-sm3">
            <!-- 填充内容 -->
            <div class="layui-card">
                <div class="layui-card-body" style="text-align: center;">
                    <p>总充值<span style="cursor:pointer;" title="总充值即为截至昨日平台已支付订单金额总和"><img src="" alt=""></span></p>
                    <p class="money">￥{$info.recharge_amount}</p>
                </div>
            </div>
        </div>
        <div class="layui-col-sm3">
            <div class="layui-card">
                <div class="layui-card-body" style="text-align: center;">
                    <p>总分成<span style="cursor:pointer;" title="总分成即为截至昨日代理分成金额总和"><img src="" alt=""></span></p>
                    <p class="money">￥{$info.commission_amount}</p>
                </div>
            </div>
        </div>
        <div class="layui-col-sm3">
            <div class="layui-card">
                <div class="layui-card-body" style="text-align: center;">
                    <p>未提现<span style="cursor:pointer;" title="未提现即为截至目前代理商未提现的平台分成金额总和"><img src="" alt=""></span></p>
                    <p class="money">￥{$info.ud_amount}</p>
                </div>
            </div>
        </div>
        <div class="layui-col-sm3">
            <div class="layui-card">
                <div class="layui-card-body" style="text-align: center;">
                    <p>提现中<span style="cursor:pointer;" title="提现中即为截至目前代理商已审未打款金额总和"><img src="" alt=""></span></p>
                    <p class="money">￥{$info.wp_amount}</p>
                </div>
            </div>
        </div>
        <div class="layui-col-sm3">
            <div class="layui-card">
                <div class="layui-card-body" style="text-align: center;">
                    <p>已打款<span style="cursor:pointer;" title="已打款即为截至目前代理商已打款金额总和"><img src="" alt=""></span></p>
                    <p class="money">￥{$info.paid_amount}</p>
                </div>
            </div>
        </div>
    </div>

    <div class="layui-row">

        <div class="layui-col-md12">
            <div class="layui-card">

                <div lay-filter="listSearch" class="layui-form layui-card-header layuiadmin-card-header-auto" style="height:auto;padding:10px 15px;">

                    <div class="layui-form-item">

                        <div class="layui-inline">
                            <select name="eb_id" lay-search>
                                <option value="">选择上级商务</option>
                                {volist name="ebs" id="v"}
                                <option value="{$v.id}">{$v.account}</option>
                                {/volist}
                            </select>
                        </div>

                        <div class="layui-inline">
                            <select name="agent_id" lay-search>
                                <option value="">选择代理</option>
                                {volist name="agents" id="v"}
                                <option value="{$v.id}">{$v.account}</option>
                                {/volist}
                            </select>
                        </div>

                        <div class="layui-inline">
                            <input type="text" id="dayEnd" name="end_date" placeholder="结算日期" autocomplete="off" class="layui-input">
                        </div>



                        <div class="layui-inline">
                            <button class="layui-btn layui-btn-normal layuiadmin-btn-admin" lay-submit lay-filter="LAY-list-front-search">
                                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                            </button>
                            <button type="button" class="layui-btn layui-btn-primary" lay-submit lay-filter="LAY-reset">重置</button>
                        </div>

                    </div>

                </div>

                <div class="layui-card-body">

                    <div style="padding-bottom: 10px;">
                        <button class="layui-btn layui-btn-normal layuiadmin-btn-useradmin" data-type="export">导出</button>
                    </div>

                    <table id="LAY-list-manage" lay-filter="LAY-list-manage"></table>

                    <script type="text/html" id="table-tool">

                        <a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="preview">提现明细</a>

                    </script>

                </div>

            </div>
        </div>

    </div>

</div>

<script src="/static/layuiadmin/layui/layui.js"></script>
<script>

    layui.use('laydate', function () {
        var $ = layui.$;
        var laydate = layui.laydate;
        var myDate = new Date();
        var maxtime = myDate.getFullYear() + "-" + (myDate.getMonth() + 1) + "-" + (myDate.getDate());
        //初始化选择时间控件
        laydate.render({
            elem: '#dayEnd'
            , type: 'date'
            , range: '~'
            , max: maxtime//设置选择最大时间为当前
            , calendar: true
            , btns: ['clear', 'confirm', 'now']
            , done: function (value, date) {
                //这里时选中后触发事件
                //value是选中的值
                var time = value;

            }
        });
    });

    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','table','admin'], function(){

        var $ = layui.$
            ,form = layui.form
            ,table = layui.table;

        //监听搜索
        var search_data = '';
        form.on('submit(LAY-list-front-search)', function(data){
            var field = data.field;
            search_data = data.field;
            //执行重载
            table.reload('LAY-list-manage', {
                where: field
                ,page: {
                    curr: 1  // 将页码重置为第一页
                }
            });
        });

        form.on('submit(LAY-reset)', function(data){
            search_data = '';
            form.val("listSearch", {
                "eb_id": "",
                "agent_id": "",
                "end_date":""
            });
            form.render();
            table.reload('LAY-list-manage', {
                where: {"eb_id": "","agent_id": "", "end_date":""}
                ,page: {
                    curr: 1  // 将页码重置为第一页
                }
            });
        });

        //书籍管理
        table.render({
            elem: '#LAY-list-manage'
            ,url: "{:url('Withdrawal/agent_summary_data')}" //模拟接口
            ,autoSort: false
            ,cols: [[
                {field: 'id', width: 100, title: '代理ID', sort: true, align:'center'}
                ,{field: 'eb_name', title: '上级商务', align:'center'}
                ,{field: 'agent_name', title: '代理商', align:'center'}
                ,{field: 'recharge_amount', title: '总充值（元）', align:'center'}
                ,{field: 'commission_amount', title: '总分成（元）', align:'center'}
                ,{field: 'ud_amount', title: '未提现（元）', align:'center'}
                ,{field: 'wp_amount', title: '提现中（元）', align:'center'}
                ,{field: 'paid_amount', title: '已打款（元）', align:'center'}
                ,{field: 'settlement_date', title: '最近结算日期', align:'center'}
                ,{title: '操作', width: 120, align:'center', fixed: 'right', toolbar: '#table-tool'}
            ]]
            ,page: true
            ,limit: 30
            ,height: 'full-220'
            ,text: '对不起，加载出现异常！'
        });

        //触发排序事件
        table.on('sort(LAY-list-manage)', function(obj){

            table.reload('LAY-list-manage', {
                initSort: obj //记录初始排序，如果不设的话，将无法标记表头的排序状态。
                ,where: { //请求参数（注意：这里面的参数可任意定义，并非下面固定的格式）
                    field: obj.field //排序字段
                    ,order: obj.type //排序方式
                }
            });

        });

        //监听工具条
        table.on('tool(LAY-list-manage)', function(obj){

            if(obj.event === 'preview'){

                layer.open({
                    type: 2
                    ,title: '代理提现明细'
                    ,content: "{:url('Withdrawal/index_agent')}?id="+obj.data.id
                    ,maxmin: true
                    ,area: ['100%', '100%']
                    ,btn: ['关闭']
                    ,btnAlign: 'c'
                    ,yes: function(index, layero){
                        layer.close(index); //关闭弹层
                    }
                });

            }

        });

        var active = {
            export:function (){
                var queryString = $.param(search_data);
                window.location.href = "{:url('Withdrawal/agent_summary_export')}?"+queryString+'';
            }
        };

        $('.layuiadmin-btn-useradmin').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });
</script>
</body>
</html>